
/*
Copyright 2009 Peter Ekler, Akos Ludanyi, Budapest University of Technology and Economics, Department of Automation and Applied Informatics, Applied Mobile Research Group (AMORG) http://amorg.aut.bme.hu

This file is part of MobTorrent.

MobTorrent is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

MobTorrent is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with MobTorrent.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ui;

import data.LocalizationSupport;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;

/**
 *
 * @author Tyrael
 */
public class MTFormUpdate extends Form implements CommandListener
{
    public static final int ScreenID = 9;

    private MTUIManager uiManager;
    private Command command_Back;
    private Command command_Update;
    private ChoiceGroup choiceGroupUpdateServer;

    public MTFormUpdate(MTUIManager aUiManager)
    {
        super(LocalizationSupport.getMessage("command_help"));

        choiceGroupUpdateServer = new ChoiceGroup(LocalizationSupport.getMessage("label_updateServer")+":", Choice.EXCLUSIVE);
        choiceGroupUpdateServer.append("Mirror 1", null);
        choiceGroupUpdateServer.append("Mirror 2", null);
        choiceGroupUpdateServer.setSelectedIndex(0, true);
        append(choiceGroupUpdateServer);

        uiManager = aUiManager;

        command_Back = new Command(LocalizationSupport.getMessage("command_back"), Command.BACK, 0);
        command_Update = new Command(LocalizationSupport.getMessage("command_update"), Command.SCREEN, 1);
        addCommand(command_Back);
        addCommand(command_Update);
        setCommandListener(this);
    }

    public void commandAction(Command c, Displayable d)
    {
        if (c == command_Back)
        {
            uiManager.showScreen(MTFormSettings.ScreenID);
        }
        else if (c == command_Update)
        {
            uiManager.getMidlet().executeUpdate(choiceGroupUpdateServer.getSelectedIndex());
        }
    }
}

